home *** CD-ROM | disk | FTP | other *** search
/ ftp.whtech.com / ftp.whtech.com.tar / ftp.whtech.com / datasheets and manuals / Hardware / WHT / scsi / dsr_sources_2_2001 / getddr < prev    next >
Text File  |  2006-10-19  |  12KB  |  476 lines

  1. * Function GETDDR - GET Directory Descriptor Record
  2. *
  3. * This function will take the name of the file in the
  4. * FCN (Filename Compare Buffer) and get the DDR of the
  5. * directory the file is named in.  If it is already in
  6. * memory, it will set R5 to point to the DDR.  If it
  7. * is not already in memory, it will read it from the
  8. * disk.  If it cannot read it from the disk for any reason,
  9. * it will return a 0 in R5.
  10. *
  11. * Register Usage:
  12. *   R5  - points to DDR in memory
  13. *   R10 - Flag to indicate if we found the directory we
  14. *         want or a higher level directory
  15. *
  16. * Output:
  17. *   R5 - Points to the ddr in RAM bank 3
  18. *        R5 = 0 if the DDR is not found
  19. *   SAVEAU - contains the AU of the ddr
  20. *
  21.  
  22. GETDDR CLR  R10              Set flag for directory
  23.        ANDI R12,>FF00        Make sure R12 is base CRU address
  24.        AI   R12,24
  25.        LDCR @B04,4           Select RAM bank 4
  26.  
  27.        LI   R2,NCB+40        Search for last period '.'
  28. GDDR2  DEC  R2
  29.        CI   R2,NCB-1         If there are no periods,
  30.        JEQ  GDDR3              then we have to read the VIB
  31.        CB   *R2,@PERIOD
  32.        JNE  GDDR2
  33.  
  34. * Now search all subdirectory names in the cache for a match
  35. *
  36. GDDR3
  37.        BLWP @FDDR
  38.        JEQ  GDDR10
  39.  
  40. * The directory name is not in cache.  We will have to try
  41. * the next higher level directory.
  42. *
  43.        SETO R10
  44.        CI   R2,NCB-1         See if we have to read the VIB
  45.        JNE  GDDR2
  46.  
  47. * OK, we will have to read in the VIB.
  48. *
  49.        CLR  R7               Select sector #0
  50.        CLR  R8
  51.        LDCR @ZERO,4          Select RAM bank 0
  52.        BLWP @BANKIT
  53.        DATA SCSIRD
  54.        JEQ  GDDR4
  55.        AI   R8,16            Try reading the copy
  56.        BLWP @BANKIT
  57.        DATA SCSIRD
  58.        JEQ  GDDR4
  59.        CLR  R5               An error occurred
  60.        RT
  61.  
  62. GDDR4  LI   R5,SECBUF        Store the volume label in our table
  63.        MOV  R6,R7
  64.        SRL  R7,8
  65.        MPY  @TEN,R7
  66.        AI   R8,DLTABL
  67.  
  68. GDDR4A MOV  *R5+,R7
  69.        LDCR @B02,4
  70.        MOV  R7,*R8+
  71.        LDCR @ZERO,4
  72.        CI   R5,SECBUF+10
  73.        JNE  GDDR4A
  74.  
  75.        LDCR @B04,4           Select RAM bank 4
  76.        BLWP @RESDCE          Reserve a Directory Cache Entry
  77.  
  78. * Now R4 points to DCE
  79. *     R5 points to DDR
  80.  
  81. * Set up Directory cache entry
  82. *
  83.        MOVB R6,*R4+          Put in SCSI ID
  84.        MOVB @B03,*R4+        Put in RAM bank of DDR
  85.        MOV  R5,*R4+          Put in DDR address
  86.        AI   R4,40            Blank out the name
  87.        CLR  *R4+             Set AU to 0
  88.        SETO *R4              Set age to -1 so it doesn't get swapped out
  89.  
  90. * Now copy the VIB to the DDR cache
  91. *
  92.  
  93.        LI   R1,SECBUF        SCSI buffer address
  94.        LI   R0,256
  95. GDDR6  LDCR @ZERO,4          Select RAM bank 0
  96.        MOV  *R1+,R2
  97.        LDCR @B03,4           Select RAM bank 3
  98.        MOV  R2,*R5+
  99.        DECT R0
  100.        JNE  GDDR6
  101.  
  102.        AI   R5,-256          Now get the Sectors/AU from the VIB
  103.        MOV  @10(R5),R0       Get disk size
  104.        MOV  @16(R5),R5
  105.        SRL  R5,12
  106.        INC  R5
  107.        LDCR @B04,4           Select RAM bank 4
  108.        MOV  R6,R4
  109.        SRL  R4,8
  110.        SLA  R4,1
  111.        MOV  R5,@SAUTBL(R4)
  112.        MOV  R0,@DSZTBL(R4)
  113.  
  114.        B    @GETDDR          Now try it again
  115.  
  116. ************************************************************
  117. *
  118. * Here is where we have to look at subdirectory names to
  119. * get the next DDR.  Unless of course, we have the DDR we
  120. * want.
  121. *
  122.  
  123. GDDR10 MOV  @44(R4),@SAVEAU
  124.        MOV  @2(R4),R5        See if DDR is in memory
  125.        JNE  GDDR16
  126.  
  127.        MOV  @44(R4),R7       OK, we need to read it into memory
  128.        LI   R3,SECBUF        Pointer to SCSI buffer
  129.        MOV  R6,R5            Get AU of DDR
  130.        SRL  R5,8
  131.        SLA  R5,1
  132.        MPY  @SAUTBL(R5),R7   Multiply AU by Sectors/AU
  133.        SRL  R8,1             Divide by 2
  134.        JNC  GDDR11
  135.        AI   R3,>100          We will use last 256 bytes
  136. GDDR11 SRL  R7,1
  137.        JNC  GDDR12
  138.        AI   R8,>8000
  139. GDDR12 BLWP @BANKIT          Read the DDR from the drive
  140.        DATA SCSIRD
  141.        JEQ  GDDR14
  142.        CLR  R5               Error, return a zero
  143.        RT
  144.  
  145. * Copy the 256 byte sector from the SCSI buffer to the
  146. * DDR cache
  147.  
  148. GDDR14 LDCR @B04,4           Select RAM bank 4
  149.        BLWP @FREDCE
  150.        LI   R1,256
  151. GDDR15 LDCR @ZERO,4          Select RAM bank 0
  152.        MOV  *R3+,R7
  153.        LDCR @B03,4           Select RAM bank 3
  154.        MOV  R7,*R5+
  155.        DECT R1
  156.        JNE  GDDR15
  157.  
  158.        AI   R5,-256          Restore pointer
  159.  
  160. GDDR16 CI   R10,0            See if we are done
  161.        JNE  GDDR17
  162.        LDCR @B04,4           Update age if necessary
  163.        C    @46(R4),@>5FFE
  164.        JH   GDR16A
  165.        JEQ  GDR16A
  166.        INC  @>5FFE
  167.        MOV  @>5FFE,@46(R4)
  168. GDR16A
  169.        RT
  170.  
  171. * Move the directory name to the file name compare buffer in bank 0.
  172. *
  173. GDDR17 INC  R2
  174.        LI   R3,FNCB
  175. GDDR18 LDCR @B04,4           Select RAM bank 4
  176.        CB   *R2,@PERIOD
  177.        JEQ  GDR18A
  178.        MOVB *R2+,R4
  179.        LDCR @ZERO,4          Select RAM bank 0
  180.        MOVB R4,*R3+
  181.        JMP  GDDR18
  182.  
  183. GDR18A LDCR @ZERO,4
  184. GDDR19 CI   R3,FNCB+10       See if we need to pad with spaces
  185.        JEQ  GDDR20
  186.        MOVB @SPACE,*R3+
  187.        JMP  GDDR19
  188.  
  189. * Now start reading directory names
  190. *
  191. * We do a binary search of the subdirectory names in the DDR
  192. *
  193. GDDR20 LDCR @B04,4           Select RAM bank 4
  194.        MOV  R6,R3            Get the number of sectors/AU for this device
  195.        SRL  R3,8
  196.        SLA  R3,1
  197.        MOV  @SAUTBL(R3),R3
  198.  
  199.        LDCR @B03,4           Select RAM bank 3
  200.        CLR  R0               R0 points to lower bound of subdirectories
  201.        MOVB @23(R5),R1       Get the number of subdirectories
  202.        JNE  GDDR21           If this directory has no subdirectories,
  203. GDDERR CLR  R5               then return a null pointer
  204.        RT
  205.  
  206. GDDR21 SRL  R1,8
  207.        DEC  R1
  208.  
  209. GDDR22 LDCR @B03,4           Select RAM bank 3
  210.        MOV  R0,R10           Calculate the midpoint
  211.        A    R1,R10
  212.        ANDI R10,>FFFE
  213.        A    R5,R10
  214.        MOV  @28(R10),R7      Get AU of subdirectory we want to check
  215.        LDCR @B04,4           Select RAM bank 4
  216.        MOV  R7,@SAVEAU       Save the AU to put in the cache entry
  217.        MPY  R3,R7            convert AU to SCSI sector
  218.        LI   R4,SECBUF        R4 points to SCSI buffer
  219.        SRL  R8,1
  220.        JNC  GDDR23
  221.        AI   R4,>0100         Read upper 256 bytes of 512 byte buffer
  222. GDDR23 SRL  R7,1
  223.        JNC  GDDR24
  224.        AI   R8,>8000
  225. GDDR24 LDCR @ZERO,4          Select ram bank 0
  226.        BLWP @BANKIT          Read DDR from SCSI drive
  227.        DATA SCSIRD
  228.        JNE  GDDERR           Branch if there was a read error
  229.  
  230. * Now compare the directory name to the one in the FNCB
  231. *
  232.        LI   R7,FNCB
  233.        LI   R9,10
  234. GDDR25 C    *R4+,*R7+
  235.        JH   GDDR28
  236.        JL   GDDR29
  237.        DECT R9
  238.        JNE  GDDR25
  239.  
  240. * We have a match - reserve a DCE and copy the DDR
  241. *
  242.        AI   R4,-10           Restore pointer to DDR in SCSI buffer
  243.        MOV  R4,R7            Save pointer
  244.        LDCR @B04,4           Select RAM bank 4
  245.        BLWP @RESDCE
  246.  
  247. * Now fill in the Directory Name Cache Entry
  248. *
  249.        MOVB R6,*R4+          Store SCSI ID
  250.        MOVB @B03,*R4+        Put in RAM bank of the DDR
  251.        MOV  R5,*R4+          Put in the DDR address
  252.  
  253. * Now fill in the name of the directory
  254. *
  255.        MOV  R4,R3
  256.        LI   R1,NCB
  257. GDDR26 MOVB *R1+,*R3+
  258.        C    R1,R2
  259.        JNE  GDDR26
  260.  
  261. * Put in the AU
  262. *
  263.        MOV  @SAVEAU,@40(R4)
  264.  
  265. * And finally put in the age to complete the entry
  266. *
  267.        INC  @>5FFE
  268.        MOV  @>5FFE,@42(R4)
  269.  
  270. * Now copy the DDR
  271. *
  272.        LI   R1,256
  273. GDDR27 LDCR @ZERO,4          Select RAM bank 0
  274.        MOV  *R7+,R8
  275.        LDCR @B03,4           Select RAM bank 3
  276.        MOV  R8,*R5+
  277.        DECT R1
  278.        JNE  GDDR27
  279.  
  280. * Now since we've destroyed R5 and R10, just go back to
  281. * the beginning of the subroutine.  We'll find this
  282. * directory in cache, so it shouldn't take very long.
  283. *
  284.        B    @GETDDR
  285.  
  286.  
  287. * If the names didn't match, select another directory name
  288. * to search.  If there are none left, return a null pointer.
  289. *
  290. GDDR28 C    R0,R1
  291.        JEQ  GDDERR
  292.        MOV  R0,R10
  293.        A    R1,R10
  294.        SRL  R10,1
  295.        C    R10,R0
  296.        JEQ  GDDERR
  297.        MOV  R10,R1
  298.        DEC  R1
  299.        JMP  GDDR22
  300.  
  301. GDDR29 C    R0,R1
  302.        JEQ  GDDERR
  303.        MOV  R0,R10
  304.        A    R1,R10
  305.        SRL  R10,1
  306.        MOV  R10,R0
  307.        INC  R0
  308.        JMP  GDDR22
  309.  
  310.  
  311. ************************************************************
  312. *
  313. * Function GETFDR
  314. *
  315. * This function will try to get the File Descriptor Record
  316. * of the file specified in the name compare buffer.  If it
  317. * is successful, it will copy the FDR into the SCSI buffer
  318. * and return a pointer to it.
  319. *
  320. * Output:
  321. *    R5 points to FDR in RAM bank 0 if found
  322. *       R5 = 0 if FDR not found
  323. *    SAVEAU contains the AU of the FDR on disk
  324. *
  325. **********************************************************
  326.  
  327. GETFDR ANDI R12,>FF00
  328.        AI   R12,24
  329.        LDCR @B02,4       Select RAM bank 2
  330.        MOV  R11,@GFDRRT  Save return address
  331.  
  332.        BL   @GETDDR      Get the DDR first
  333.  
  334.        CI   R5,0
  335.        JEQ  GFDR98
  336.  
  337. * Check to make sure the number of files in the directory
  338. * does not equal zero.
  339.  
  340.        LDCR @B03,4       Select RAM bank 3
  341.        MOVB @22(R5),R1   Get the number of files
  342.        JEQ  GFDR98
  343.  
  344. * Read the file index and store it in DFDR
  345. *
  346.        MOV  @24(R5),R7   Get AU of the file index
  347.        LDCR @B04,4
  348.        MOV  R6,R3
  349.        SRL  R3,8
  350.        SLA  R3,1
  351.        MPY  @SAUTBL(R3),R7
  352.  
  353.        LI   R5,SECBUF    Point to SCSI buffer
  354.        SRL  R8,1
  355.        JNC  GFDR1
  356.        AI   R5,>100
  357. GFDR1  SRL  R7,1
  358.        JNC  GFDR2
  359.        AI   R8,>8000
  360. GFDR2  LDCR @ZERO,4
  361.        BLWP @BANKIT      Read the index from disk
  362.        DATA SCSIRD
  363.        JNE  GFDR98
  364.  
  365. * Copy the filename to the filename compare buffer (FNCB)
  366. *
  367.        LDCR @B02,4       Select RAM bank 2
  368.        LI   R2,NCB+39
  369. GFDR3  CB   *R2,@PERIOD
  370.        JEQ  GFDR4
  371.        DEC  R2
  372.        CI   R2,NCB-1
  373.        JNE  GFDR3
  374.  
  375. GFDR4  INC  R2
  376.        LI   R4,FNCB
  377. GFDR5  CI   R2,NCB+40
  378.        JEQ  GFDR6
  379.        CB   *R2,@SPACE
  380.        JEQ  GFDR6
  381.        MOVB *R2+,R3
  382.        LDCR @ZERO,4
  383.        MOVB R3,*R4+
  384.        LDCR @B02,4
  385.        JMP  GFDR5
  386.  
  387. GFDR6  LDCR @ZERO,4      Pad the rest of the name with spaces
  388. GFDR6A CI   R4,FNCB+10
  389.        JEQ  GFDR7
  390.        MOVB @SPACE,*R4+
  391.        JMP  GFDR6A
  392.  
  393. * Here is where we return to the calling program
  394. *
  395. GFDR98 CLR  R5           We did not find the FDR
  396. GFDR99 LDCR @B02,4       Select RAM bank 2
  397.        MOV  @GFDRRT,R11  Get our return address
  398.        RT
  399.  
  400. GFDR7
  401.  
  402. * set the bounds for our binary search
  403. *
  404.        SRL  R1,8
  405.        CLR  R0
  406.  
  407. * Copy the file index from the SCSI buffer to DFDR
  408. *
  409.        LI   R2,DFDR
  410.        MOV  R1,R3
  411.        DEC  R1
  412. GFDR8  LDCR @ZERO,4
  413.        MOV  *R5+,R4
  414.        LDCR @B02,4
  415.        MOV  R4,*R2+
  416.        DEC  R3
  417.        JNE  GFDR8
  418.  
  419. GFDR9  LDCR @B02,4
  420.        MOV  R0,R2        Calculate the midpoint for the
  421.        A    R1,R2        binary search
  422.        ANDI R2,>FFFE
  423.        MOV  @DFDR(R2),R7 Get AU of FDR we want to check
  424.        LDCR @B04,4       Select RAM bank 4
  425.        MOV  R7,@SAVEAU   Save the AU in case this is the one
  426.        MOV  R6,R3
  427.        SRL  R3,8
  428.        SLA  R3,1
  429.        MPY  @SAUTBL(R3),R7
  430.        LDCR @ZERO,4
  431.        LI   R5,SECBUF
  432.        SRL  R8,1
  433.        JNC  GFDR10
  434.        AI   R5,>100
  435. GFDR10 SRL  R7,1
  436.        JNC  GFDR11
  437.        AI   R8,>8000
  438. GFDR11 BLWP @BANKIT      Read the FDR from disk
  439.        DATA SCSIRD
  440.        JNE  GFDR98
  441.  
  442. * Now compare the filename
  443. *
  444.        LI   R3,FNCB
  445. GFDR12 C    *R5+,*R3+
  446.        JL   GFDR13
  447.        JH   GFDR14
  448.        CI   R3,FNCB+10
  449.        JNE  GFDR12
  450.  
  451.        AI   R5,-10       We found it!!!
  452.        JMP  GFDR99
  453.  
  454. * The file name did not match.  Modify the bounds
  455. * of our binary search
  456. *
  457. GFDR13 C    R0,R1        Is there anything left to check?
  458.        JEQ  GFDR98       If not, error
  459.        MOV  R0,R2        Recompute the midpoint
  460.        A    R1,R2
  461.        SRL  R2,1
  462.        MOV  R2,R0        Modify lower bound of the search
  463.        INC  R0
  464.        JMP  GFDR9
  465.  
  466. GFDR14 C    R0,R1        Is there anything left to check?
  467.        JEQ  GFDR98       If not, error
  468.        MOV  R0,R2        Recompute the midpoint
  469.        A    R1,R2
  470.        SRL  R2,1
  471.        C    R2,R0
  472.        JEQ  GFDR98
  473.        MOV  R2,R1        Modify the upper bound of the search
  474.        DEC  R1
  475.        JMP  GFDR9
  476.